package magicloan.auctionpocket.adapter;

import android.content.Context;
import android.content.Intent;
import android.support.annotation.LayoutRes;
import android.support.annotation.Nullable;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;

import java.util.List;

import magicloan.auctionpocket.R;
import magicloan.auctionpocket.bean.ProduceBean;
import magicloan.auctionpocket.interfacepackage.RecylerViewRemoveListener;
import magicloan.auctionpocket.ui.activity.AddAddressActivity;

/**
 * Created by hechao on 2018/1/31.
 */
public class MyAddressAdapter extends BaseQuickAdapter<ProduceBean, BaseViewHolder> {

    private Context mContext ;
    private RecylerViewRemoveListener mRecylerViewRemoveListener ;
    public MyAddressAdapter(@LayoutRes int layoutResId, @Nullable List<ProduceBean> data) {
        super(layoutResId, data);
    }

    public MyAddressAdapter(@Nullable List<ProduceBean> data) {
        super(data);
    }

    public MyAddressAdapter(@LayoutRes int layoutResId) {
        super(layoutResId);
    }

    public MyAddressAdapter(int layoutResId, Context activity , RecylerViewRemoveListener listener ) {
        super(layoutResId);
        mContext = activity ;
        mRecylerViewRemoveListener = listener ;
    }

    @Override
    protected void convert(BaseViewHolder helper, ProduceBean item, final int position) {
        TextView tv_name = helper.getView(R.id.tv_name);
        TextView tv_phone = helper.getView(R.id.tv_phone);
        TextView tv_address = helper.getView(R.id.tv_address);
        ImageView img_check = helper.getView(R.id.img_check);
        helper.getView(R.id.tv_edit).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {

                Intent intent = new Intent(mContext, AddAddressActivity.class);
                mContext.startActivity(intent);

            }
        });
        helper.getView(R.id.tv_delete).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                mRecylerViewRemoveListener.onRemove(position);
            }
        });
    }

}
